package com.neu.util;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.work.Data;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

public class MyWork extends Worker {
    public MyWork(@NonNull Context context, @NonNull WorkerParameters workerParams) {
        super(context, workerParams);
    }

    @NonNull
    @Override
    public Result doWork() {
        Log.d("TAG", "doWork:开始执行 ");
        //获得前台的数据
        Data data=getInputData();
        if(data!=null)
        Log.d("TAG", "获得前台的数据："+data.getString("str"));

        //向前太传数据
        Data out=new Data.Builder()
                .putString("back","数据成功传后台")
                .build();
        return Result.success(out);
    }
}
